import axios from 'axios'
import { Message } from 'element-ui'
// import qs from 'qs'

const service = axios.create({
    baseURL: 'http://127.0.0.1:4523/m1/1182527-0-default',
    timeout: 10000
})


service.interceptors.request.use(
    config => {
        // config.headers['Authorization'] = sessionStorage.getItem('token')
        // url参数格式化
        // if (config.method === 'get' || config.method === 'delete') {
        //     config.paramsSerializer = function (params) {
        //         return qs.stringify(params, { arrayFormat: 'repeat' })
        //     }
        // }
        return config;
    }, error => {
        return Promise.error(error)
    }
)


// 添加响应拦截器
service.interceptors.response.use(
    response => {
        let data = response.data;
        return Promise.resolve(data);

    }, error => {
        // 对响应错误做点什么
        console.log('==============error=================')
        console.log("error:" + error)
        Message.error(error)
        return Promise.reject(error);
    })




export default service